<template>
<div class="after-sale-detail views-container">
    <el-dialog :visible.sync="dialogTableVisible" custom-class="reset-pwd wlm-form-dialog dialog-table">
        <div class="wlm-form" v-if="dialogTableVisible">
            <div class="wlm-form-header wlm-dialog-fixheader">
                <span class="wlm-dialog-inlenr">{{formType == '1'?'商家发货':formType == '2'? '审核申请' :formType == '3'?'审核换货':formType == '4'?'退款':'-'}}</span>
            </div>
            <el-scrollbar wrap-class="scrollbar-wrapper">
                <div class="wlm-form-content">
                    <div class="wlm-dialog-main">
                        <div class="wlm-dialog-content">
                            <el-form ref="userForm" :model="formFormatData.formData" :rules="formFormatData.rules" size="small" label-width="120px" class="retail-form" label-position="right">
                                <template v-if="formType === '1'">
                                    <el-form-item label="默认快递公司" prop="express_name">
                                        <el-select v-model="formFormatData.formData.express_name" placeholder="请选择">
                                            <el-option v-for="(item,index) in expressList" :key="index" :label="item" :value="item">
                                            </el-option>
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item label="物流单号" prop="express_no">
                                        <el-input v-model.trim="formFormatData.formData.express_no">
                                        </el-input>
                                    </el-form-item>
                                </template>
                                <template v-if="formType === '2'">
                                    <el-form-item label="同意申请">
                                        <el-radio-group v-model="formFormatData.formData.is_agree">
                                            <el-radio label="10">同意</el-radio>
                                            <el-radio label="20">不同意</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                    <el-form-item label="原因" prop="reason" v-if="formFormatData.formData.is_agree === '20'">
                                        <el-input v-model.trim="formFormatData.formData.refuse_desc">
                                        </el-input>
                                    </el-form-item>
                                    <el-form-item label="收货人姓名" v-if="formFormatData.formData.is_agree === '10'">
                                        <el-input v-model="formFormatData.formData.receive_name">
                                        </el-input>
                                    </el-form-item>
                                    <el-form-item label="联系电话" v-if="formFormatData.formData.is_agree === '10'">
                                        <el-input v-model="formFormatData.formData.receive_phone">
                                        </el-input>
                                    </el-form-item>
                                    <el-form-item label="发货地址" v-if="formFormatData.formData.is_agree === '10'">
                                        <el-input v-model="formFormatData.formData.receive_detail">
                                        </el-input>
                                    </el-form-item>
                                </template>
                                <template v-if="formType === '3'">
                                    <el-form-item label="审核换货">
                                        <el-radio-group v-model="formFormatData.formData.is_agree">
                                            <el-radio label="10">同意</el-radio>
                                            <el-radio label="20">不同意</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                    <el-form-item label="原因" prop="reason" v-if="formFormatData.formData.is_agree === '20'">
                                        <el-input v-model.trim="formFormatData.formData.refuse_desc">
                                        </el-input>
                                    </el-form-item>
                                    <el-form-item label="收货人姓名" v-if="formFormatData.formData.is_agree === '10'">
                                        <el-input v-model="formFormatData.formData.receive_name">
                                        </el-input>
                                    </el-form-item>
                                    <el-form-item label="联系电话" v-if="formFormatData.formData.is_agree === '10'">
                                        <el-input v-model="formFormatData.formData.receive_phone">
                                        </el-input>
                                    </el-form-item>
                                    <el-form-item label="发货地址" v-if="formFormatData.formData.is_agree === '10'">
                                        <el-input v-model="formFormatData.formData.receive_detail">
                                        </el-input>
                                    </el-form-item>
                                </template>
                                <template v-if="formType === '4'">
                                    <el-form-item label="是否退款">
                                        <el-radio-group v-model="formFormatData.formData.is_agree" @change="refundChange">
                                            <el-radio label="10">同意</el-radio>
                                            <el-radio label="20">不同意</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                    <el-form-item label="原因" v-if="formFormatData.formData.is_agree === '20'">
                                        <el-input  type="textarea" v-model.trim="formFormatData.formData.refuse_desc">
                                        </el-input>
                                    </el-form-item>
                                    <el-form-item label="退款金额" v-if="formFormatData.formData.is_agree=='10'">
                                        <el-input v-model.trim="formFormatData.formData.refund_money">
                                        </el-input>
                                    </el-form-item>
                                </template>
                            </el-form>
                        </div>
                    </div>
                </div>
            </el-scrollbar>
        </div>
        <footer class="flex-row flex-align-c flex-justify-c wlm-dialog-fixfooter">
            <el-button size="small" type="primary" :disabled="isFormFormatSave" :loading="isFormFormatSave" @click="formFormatSubmit">确定</el-button>
        </footer>
    </el-dialog>

    <div class="wlm-form" style="border-radius:0;">
        <div class="wlm-form-steps flex-row flex-align-c flex-justify-c">
            <el-steps align-center :active="orderStep" v-if="formFormatData.formData.type=='30'">
                <el-step title="售后申请">
                    <div slot="description">{{formFormatData.formData.create_time}}</div>
                </el-step>
                <el-step title="申请处理">
                    <div v-if="formFormatData.formData.examine_time!=0" slot="description">{{formFormatData.formData.examine_time | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</div>
                </el-step>
                <el-step title="已完成">
                    <div v-if="formFormatData.formData.complete_time!=0&&formFormatData.formData.is_agree_sss!='20'" slot="description">{{formFormatData.formData.complete_time | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</div>
                </el-step>
            </el-steps>
            <el-steps align-center :active="orderStep2" v-if="formFormatData.formData.type=='10'">
                <el-step title="售后申请">
                    <div slot="description">{{formFormatData.formData.create_time}}</div>
                </el-step>
                <el-step title="申请处理">
                    <div v-if="formFormatData.formData.examine_time!=0" slot="description">{{formFormatData.formData.examine_time | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</div>
                </el-step>
                <el-step title="用户发货">
                    <div v-if="formFormatData.formData.send_time!=0" slot="description">{{formFormatData.formData.send_time | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</div>
                </el-step>
                <el-step title="商户退款">
                    <div v-if="formFormatData.formData.complete_time!=0&&formFormatData.formData.is_agree_sss!='20'" slot="description">{{formFormatData.formData.complete_time | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</div>
                </el-step>
            </el-steps>
            <el-steps align-center :active="orderStep3" v-if="formFormatData.formData.type=='20'">
                <el-step title="售后申请">
                    <div slot="description">{{formFormatData.formData.create_time}}</div>
                </el-step>
                <el-step title="申请处理">
                    <div v-if="formFormatData.formData.examine_time!=0" slot="description">{{formFormatData.formData.examine_time | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</div>
                </el-step>
                <el-step title="用户发货">
                    <div v-if="formFormatData.formData.send_time!=0" slot="description">{{formFormatData.formData.send_time | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</div>
                </el-step>
                <el-step title="商家发新货">
                    <div v-if="formFormatData.formData.store_send_time!=0" slot="description">{{formFormatData.formData.store_send_time | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</div>
                </el-step>
                <el-step title="用户收货">
                    <div v-if="formFormatData.formData.user_receipt_time!=0&&formFormatData.formData.is_agree_sss!='20'" slot="description">{{formFormatData.formData.user_receipt_time | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</div>
                </el-step>
            </el-steps>
        </div>
    </div>

    <section class="flex-row flex-warp form-group">
        <div class="wlm-form">
            <div class="wlm-form-header flex-row flex-justify-b">
                <p>售后信息</p>
            </div>
            <div class="wlm-form-content">
                <el-form :ref="formFormatData.key" :model="formFormatData.formData" :rules="formFormatData.rules" size="small" label-width="120px" class="retail-form" label-position="right">
                    <el-form-item label="售后类型：">
                        <span>{{afterSaleType[`${formFormatData.formData.type}`]}}</span>
                    </el-form-item>
                    <el-form-item label="售后状态：">
                        <span>{{afterNewStatus[`${formFormatData.formData.status_sss}`]}}</span>
                    </el-form-item>
                    <el-form-item label="售后原因：" v-if="express_type!='3'">
                        <span>{{formFormatData.formData.apply_desc}}</span>
                    </el-form-item>
                    <el-form-item label="原因说明：" v-if="express_type!='3'">
                        <span>{{formFormatData.formData.problem_desc}}</span>
                    </el-form-item>
                    <el-form-item label="退款总金额：" v-if="formFormatData.formData.type!=20">
                        <span class="orders-red">￥{{formFormatData.formData.refund_money_sss}}</span>
                    </el-form-item>
                </el-form>
            </div>
        </div>

        <div class="wlm-form">
            <div class="wlm-form-header">订单信息</div>
            <div class="wlm-form-content">
                <el-form :ref="formFormatData.key" :model="formFormatData.formData" :rules="formFormatData.rules" size="small" label-width="120px" class="retail-form" label-position="right">
                    <el-form-item label="订单编号：">
                        <p>{{formFormatData.formData.order_no}}</p>
                    </el-form-item>
                    <el-form-item label="订单类型：">
                        <span>{{orderType[`${formFormatData.formData.order_type}`]}}</span>
                    </el-form-item>
                    <el-form-item label="订单来源：">
                        <p>{{sourceType[`${formFormatData.formData.source}`]}}</p>
                    </el-form-item>
                    <el-form-item label="支付方式：">
                        <p>{{payType[`${formFormatData.formData.pay_type}`]}}</p>
                    </el-form-item>
                    <el-form-item label="订单状态：">
                        <span>{{formFormatData.formData.order_state}}</span>
                    </el-form-item>
                </el-form>
            </div>
        </div>

        <div class="wlm-form">
            <div class="wlm-form-header">其他信息</div>
            <div class="wlm-form-content">
                <el-form :ref="formFormatData.key" :model="formFormatData.formData" :rules="formFormatData.rules" size="small" label-width="160px" class="retail-form" label-position="right">
                    <el-form-item label="用户备注：">
                        <span>{{formFormatData.formData.problem_desc}}</span>
                    </el-form-item>
                </el-form>
            </div>
        </div>
    </section>
    <!-- 非核销 -->
    <div class="wlm-form" v-if="express_type!='3'">
        <div class="wlm-form-header">商品信息</div>
        <div class="wlm-form-content">
            <div class="wlm-table">
                <div class="wlm-table-content">
                    <el-table :data="[formFormatData.formData.order_goods_info]" style="width: 100%">
                        <el-table-column prop="date" label="商品" >
                            <template slot-scope="scope">
                                <span></span>
                                <div class="flex-row flex-align-c mar-b-20">
                                    <img
                      v-if="scope.row.image"
                      width="50"
                      height="50"
                      :src="scope.row.image.file_path"
                      style="margin-right: 10px;"
                    >
                                    <span>{{scope.row.goods_name}}</span>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column prop="date" label="数量" >
                            <template slot-scope="scope">
                                <p>{{scope.row.total_num}}</p>
                            </template>
                        </el-table-column>
                        <el-table-column prop="date" label="小计" >
                            <template slot-scope="scope">
                                <span class="orders-red">￥{{scope.row.total_pay_price}}</span>
                            </template>
                        </el-table-column>
                        <el-table-column prop="date" label="优惠价" >
                            <template slot-scope="scope">
                                <p v-if="!!scope.row.favorable_price" class="orders-red">￥{{scope.row.favorable_price}}</p>
                                <p v-if="!scope.row.favorable_price">-</p>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>
            </div>
        </div>
    </div>
    <!-- 核销 -->
    <div class="wlm-form" v-if="express_type=='3'">
        <div class="wlm-form-header">核销码信息</div>
        <div class="wlm-form-content">
            <div class="wlm-table">
                <div class="wlm-table-content">
                    <el-table :data="formFormatData.formData.order_vercode" style="width: 100%">
                        <el-table-column prop="date" label="核销码" >
                            <template slot-scope="scope">
                                <p>{{scope.row.code}}</p>
                                <!-- <p class="hx-box" v-for="(item, index) in formFormatData.formData.order_vercode" :key="index">{{item.code}}</p> -->
                            </template>
                        </el-table-column>
                        <el-table-column prop="date" label="状态" >
                            <template slot-scope="scope">
                                <div v-if="scope.row.is_refund==0&&(scope.row.end_time=='-1'||(scope.row.end_time!='-1'||Date.now()<scope.row.end_time*1000))">
                                    <p v-if="scope.row.check_status==0">待核销</p>
                                    <p v-if="scope.row.check_status==1">已核销</p>
                                    <p v-if="scope.row.check_status==2">已退款</p>
                                </div>
                                <div v-if="scope.row.is_refund!=0&&(scope.row.end_time=='-1'||(scope.row.end_time!='-1'||Date.now()<scope.row.end_time*1000))">
                                    <p v-if="scope.row.is_refund==30&&scope.row.check_status!=2">退款中</p>
                                    <p v-if="scope.row.is_refund==30&&scope.row.check_status==2">已退款</p>
                                </div>
                                <p v-if="scope.row.end_time!='-1'&&scope.row.is_refund==0&&scope.row.check_status==0">
                                    <span v-if="Date.now()>scope.row.end_time*1000">已过期</span>
                                </p>
                            </template>
                        </el-table-column>
                        <el-table-column prop="date" label="操作时间" >
                            <template slot-scope="scope">
                                <p v-if="scope.row.check_time!=0">{{scope.row.check_time | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</p>
                                <p v-if="scope.row.check_time==0">-</p>
                            </template>
                        </el-table-column>
                        <el-table-column prop="date" label="退款金额" >
                            <template slot-scope="scope">
                                <p v-if="formFormatData.formData.is_agree_sss=='10'">{{scope.row.pay_money || '-'}}</p>
                                <p v-if="formFormatData.formData.is_agree_sss!='10'">-</p>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>
            </div>
        </div>
    </div>
    <!-- 核销 -->
    <div class="wlm-form" v-if="express_type=='3'">
        <div class="wlm-form-header">商品信息</div>
        <div class="wlm-form-content">
            <div class="wlm-table">
                <div class="wlm-table-content">
                    <el-table :data="[formFormatData.formData.order_goods_info]" style="width: 100%">
                        <el-table-column prop="date" label="商品" >
                            <template slot-scope="scope">
                                <span></span>
                                <div class="flex-row flex-align-c mar-b-20">
                                    <img
                      v-if="scope.row.image"
                      width="50"
                      height="50"
                      :src="scope.row.image.file_path"
                      style="margin-right: 10px;"
                    >
                                    <span>{{scope.row.goods_name}}</span>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column prop="date" label="数量" >
                            <template slot-scope="scope">
                                <p>{{scope.row.total_num}}</p>
                            </template>
                        </el-table-column>
                        <el-table-column prop="date" label="小计" >
                            <template slot-scope="scope">
                                <span class="orders-red">￥{{scope.row.total_pay_price}}</span>
                            </template>
                        </el-table-column>
                        <!-- <el-table-column prop="date" label="优惠价"  >
                            <template slot-scope="scope">
                                <p>￥{{formFormatData.formData.favorable_price}}</p>
                            </template>
                        </el-table-column> -->
                    </el-table>
                </div>
            </div>
        </div>
    </div>

    <div class="wlm-form" style="margin-bottom:50px;">
        <div class="wlm-form-header flex-row flex-justify-b">
            <p>沟通记录</p>
        </div>
        <!-- 快递 -->
        <div>
            <div class="communication">
                <div style="padding:0 40px;">
                    <p><span class="orders-red">用户 &nbsp;&nbsp;</span>{{formFormatData.formData.communication_record.create_time}}</p>
                    <p>用户发起{{afterSaleType[`${formFormatData.formData.type}`]}}申请</p>
                    <p>售后原因：{{formFormatData.formData.communication_record.apply_desc}}</p>
                    <p>售后描述：{{formFormatData.formData.communication_record.problem_desc}}</p>
                    <div class="flex-row">
                        <img class="communication-img" v-for="(item, index) in formFormatData.formData.communication_record.refund_image" :key="index" :src="item.file_path" @click="imgOpen(item.file_path)" alt="">
                    </div>
                </div>
                </div>
                <div class="communication" v-if="formFormatData.formData.communication_record.is_agree!=0">
                    <div style="padding:0 40px;">
                        <p><span class="orders-red">商户 &nbsp;&nbsp;</span>{{formFormatData.formData.examine_time | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</p>
                        <div v-if="formFormatData.formData.communication_record.is_agree=='20'">
                            <p>商家不同意申请</p>
                            <p>驳回原因：{{formFormatData.formData.communication_record.refuse_desc_sss}}</p>
                        </div>
                        <div v-if="formFormatData.formData.communication_record.is_agree=='10'">
                            <p>商家同意申请</p>
                            <div v-if="formFormatData.formData.type=='20'">
                                <p>换货人昵称：{{formFormatData.formData.communication_record.nickName}}</p>
                                <p>换货人电话：{{formFormatData.formData.communication_record.mobile || '-'}}</p>
                                <p>换货地址：{{formFormatData.formData.communication_record.detail}}</p>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="communication" v-if="formFormatData.formData.communication_record.is_user_send==1">
                    <div style="padding:0 40px;">
                        <p><span class="orders-red">用户发货 &nbsp;&nbsp;</span>{{formFormatData.formData.communication_record.send_time | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</p>
                        <div>
                            <p>物流：{{formFormatData.formData.communication_record.express_id}}</p>
                            <p>物流单号：{{formFormatData.formData.communication_record.express_no}}</p>
                        </div>
                    </div>
                </div>
                <div class="communication" v-if="formFormatData.formData.type=='20'&&!!formFormatData.formData.communication_record.store_send_time">
                    <div style="padding:0 40px;">
                        <p><span class="orders-red">商户发货 &nbsp;&nbsp;</span>{{formFormatData.formData.communication_record.store_send_time | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</p>
                        <div>
                            <p>物流：{{formFormatData.formData.communication_record.store_express_name}}</p>
                            <p>物流单号：{{formFormatData.formData.communication_record.store_express_no}}</p>
                        </div>
                    </div>
                </div>
                <div class="communication" v-if="formFormatData.formData.type=='20'&&!!formFormatData.formData.user_receipt_time">
                    <div style="padding:0 40px;">
                        <p><span class="orders-red">用户确认收货 &nbsp;&nbsp;</span>{{formFormatData.formData.user_receipt_time | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</p>
                    </div>
                </div>
                <div class="communication" v-if="formFormatData.formData.type=='10'&&!!formFormatData.formData.complete_time">
                    <div style="padding:0 40px;">
                        <p><span class="orders-red">商户同意退款 &nbsp;&nbsp;</span>{{formFormatData.formData.complete_time | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</p>
                    </div>
                </div>
            </div>
            <div class="communication">
                <div style="padding:0 40px;">
                    <p><span class="orders-red">{{statusType[`${formFormatData.formData.status_sss}`]}}</span></p>
                </div>
            </div>
        </div>
        <div v-cloak class="wlm-fixed-btn flex-row flex-align-c flex-justify-c" v-if="isFormFormatGetEnd">
            <template v-if="express_type=='1'&&formFormatData.formData.is_agree_sss=='0'&&formFormatData.formData.status_sss!='4'">
                <!-- 审核申请 -->
                <el-button v-if="formFormatData.formData.type=='10'" class="wlm-text" type="primary" @click="showDialog({formType:'2',params:{id:order_refund_id,toggle:'dialogTableVisible',noEdit:true}})">审核申请</el-button>
                <!-- 审核换货 -->
                <el-button v-if="formFormatData.formData.type=='20'" class="wlm-text" type="primary" @click="showDialog({formType:'3',params:{id:order_refund_id,toggle:'dialogTableVisible',noEdit:true}})">审核换货</el-button>
            </template>
            <!-- 商家发货 -->
            <el-button v-if="formFormatData.formData.status_sss!='4'&&express_type=='1'&& formFormatData.formData.is_bus_send != '1' && formFormatData.formData.is_user_send == '1'&&formFormatData.formData.type=='20'&&formFormatData.formData.is_agree_sss=='10'" class="wlm-text" type="primary" @click="showDialog({formType:'1',params:{id:order_refund_id,toggle:'dialogTableVisible',noEdit:true}})">商家发货</el-button>
            <!-- 退款 -->
            <el-button v-if="formFormatData.formData.status_sss!='4'&&!formFormatData.formData.refund_time&&express_type!='1'&&formFormatData.formData.is_agree_sss=='0'" class="wlm-text" type="primary" @click="showDialog({formType:'4',params:{id:order_refund_id,toggle:'dialogTableVisible',noEdit:true}})">退款</el-button>
            <el-button v-if="formFormatData.formData.status_sss!='4'&&!formFormatData.formData.refund_time&&express_type=='1'&&formFormatData.formData.type=='10'&&formFormatData.formData.is_agree_sss=='10'&&formFormatData.formData.is_user_send=='1'" class="wlm-text" type="primary" @click="showDialog({formType:'4',params:{id:order_refund_id,toggle:'dialogTableVisible',noEdit:true}})">退款</el-button>
            <el-button v-if="formFormatData.formData.status_sss!='4'&&!formFormatData.formData.refund_time&&express_type=='1'&&formFormatData.formData.type=='30'&&formFormatData.formData.is_agree_sss=='0'" class="wlm-text" type="primary" @click="showDialog({formType:'4',params:{id:order_refund_id,toggle:'dialogTableVisible',noEdit:true}})">退款</el-button>
            <!-- <span v-if="formFormatData.formData.is_agree_sss=='10'||formFormatData.formData.is_agree_sss=='20'">-</span> -->
            <el-button v-if="formFormatData.formData.status_sss!='1'&&formFormatData.formData.status_sss!='5'" class="wlm-text" type="primary" @click="closeConfirm(order_refund_id)">关闭订单</el-button>
            <span v-if="formFormatData.formData.status_sss=='5'">订单已关闭</span>
        </div>
    </div>
</template>

<script>
import {
  getRefundApplyDetail,
  refundStoreSendGoods,
  RefundApplyToExamine,
  startRefund,
  getExpress,
  closeRefundApplyOrder
} from '@/api/orders'
import mixins from '@/mixins/mixins'
export default {
  mixins: [mixins.getters('Form')],
  name: 'AfterSaleDetail',
  components: {
  },
  directives: {

  },
  computed: {
    express_type() {
      return this.$route.query.express_type
    },
    order_refund_id() {
      return this.$route.query.order_refund_id
    },
    orderStep() {
      var step = 0
      const is_agree_sss = this.formFormatData.formData.is_agree_sss
      const status_sss = this.formFormatData.formData.status_sss
      const create_time = this.formFormatData.formData.create_time
      if (create_time !== 0) {
        step = 1
        if (is_agree_sss !== 0) {
          step = 2
          if (status_sss !== 1 && is_agree_sss !== 20) {
            step = 3
          }
        }
      }
      return step
    },
    orderStep2() {
      var step = 0
      const create_time = this.formFormatData.formData.create_time
      const is_agree_sss = this.formFormatData.formData.is_agree_sss
      const is_user_send = this.formFormatData.formData.is_user_send
      const status_sss = this.formFormatData.formData.status_sss
      if (create_time !== 0) {
        step = 1
        if (is_agree_sss !== 0) {
          step = 2
          if (is_user_send === 1) {
            step = 3
            if (status_sss !== 1 && is_agree_sss !== 20) {
              step = 4
            }
          }
        }
      }
      return step
    },
    orderStep3() {
      var step = 0
      const create_time = this.formFormatData.formData.create_time
      const is_agree_sss = this.formFormatData.formData.is_agree_sss
      const is_user_send = this.formFormatData.formData.is_user_send
      const is_receipt = this.formFormatData.formData.is_receipt
      const is_bus_send = this.formFormatData.formData.is_bus_send
      const status_sss = this.formFormatData.formData.status_sss
      if (create_time !== 0) {
        step = 1
        if (is_agree_sss !== 0) {
          step = 2
          if (is_user_send === 1) {
            step = 3
            if (is_receipt === 1 || is_bus_send === 1) {
              step = 4
              if (status_sss !== 1 && is_agree_sss !== 20) {
                step = 5
              }
            }
          }
        }
      }
      return step
    }
  },
  created() {
    this.$nextTick(() => {
      getExpress().then((response) => {
        const { data: { data: msgData = [] } } = response
        this.expressList = msgData
      })
    })
  },
  data() {
    return {
      dialogTableVisible: false,
      defaultMsg: '',
      sourceType: {
        '1': '导入',
        '2': '微信小程序',
        '3': 'H5',
        '4': '公众号',
        '5': '安卓',
        '6': '苹果',
        '7': '支付宝小程序',
        '8': '百度小程序',
        '9': '头条小程序',
        '-': '-'
      },
      afterSaleType: {
        '10': '退货退款',
        '20': '换货',
        '30': '退款'
      },
      afterNewStatus: {
        '1': '售后中',
        '2': '售后拒绝',
        '3': '售后完成',
        '4': '售后取消',
        '5': '售后关闭'
      },
      orderType: {
        '0': '普通订单',
        '1': '普通订单',
        '2': '拼团订单',
        '3': '秒杀订单'
      },
      payType: {
        'wechat': '微信',
        'admin': '后台确认',
        'alipay': '支付宝',
        'blance': '余额',
        'zero': '零元',
        '-': '-'
      },
      statusType: {
        '1': '进行中',
        '2': '已拒绝',
        '3': '已完成',
        '4': '已取消',
        '5': '已关闭'
      },
      platformConfig: {
        type: ['image'],
        initList: []
      },
      formFormatData: {
        key: 'smsSettings',
        model: {
          bindDialog: 'dialogTableVisible'
        },
        api: {
          editForm: {
            api: getRefundApplyDetail,
            params: {
              always: true
            }
          }
        },
        formData: {
          type: '',
          order_id: '',
          order_goods_id: '',
          problem_desc: '',
          apply_desc: '',
          is_agree_sss: '',
          refuse_desc_sss: '',
          refund_money_sss: '',
          refund_time: '',
          is_user_send: '',
          send_time: '',
          express_no_sss: '',
          is_receipt: '',
          is_bus_send: '',
          status_sss: '',
          create_time: '',
          update_time: '',
          order_no: '',
          source: '',
          pay_type: '',
          order_state: '',
          order_type: '',
          communication_record: [],
          order_goods_info: '',
          user_receipt_time: '',
          order_vercode: [],
          examine_time: '',
          complete_time: '',
          store_send_time: '',
          is_agree: '10',
          express_name: '',
          express_no: '',
          refuse_desc: '',
          receive_name: '',
          receive_phone: '',
          receive_detail: '',
          refund_money: '',
          status: '0'
        },
        rules: {
          appKey: [{
            required: true,
            message: '请输入App Key',
            trigger: 'blur'
          }],
          appSecret: [{
            required: true,
            message: '请输入App Secret',
            trigger: 'blur'
          }]
        }
      }
      //   tableFormatData: {
      //     current: 'announcement',
      //     announcement: {
      //       key: 'announcement',
      //       tableData: [],
      //       files: {
      //         status: '1',
      //         title: '',
      //         ids: [],
      //         checkall: '0',
      //         Recycle: '0'
      //       },
      //       pagination: {
      //         page: 1,
      //         list_rows: 10,
      //         pagesizes: [10, 20, 50],
      //         total: 0
      //       }
      //     }
      //   }
    }
  },
  methods: {
    imgOpen(data) {
    //   window.location.href = data
      window.open(data)
    },
    refundChange(data) {
      if (data === '10') {
        this.formFormatData.api.submitForm = startRefund
      } else if (data === '20') {
        this.formFormatData.api.submitForm = RefundApplyToExamine
      }
    },
    closeConfirm() {
      this.$confirm('是否确认关闭订单?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        closeRefundApplyOrder({ ids: [this.order_refund_id] }).then((response) => {
          this.$message({
            type: 'success',
            message: '关闭成功!'
          })
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消关闭'
        })
      })
    },
    showDialog({ formType, params }) {
      this.formFormatData.formData.refund_money = this.formFormatData.formData.order_goods_info.total_pay_price
      this.formType = formType
      if (formType === '1') {
        this.formFormatData.api.submitForm = refundStoreSendGoods
      } else if (formType === '2' || formType === '3') {
        this.formFormatData.api.submitForm = RefundApplyToExamine
      } else if (formType === '4') {
        this.formFormatData.api.submitForm = startRefund
      }
      this.formFormatDialogEditEvt(params)
    },
    formDialogEvt() {
      this.dialogTableVisible = true
    },
    formFormatCallBack(data, type, response) {
      if (type === 'submitForm') {
        this.formFormatEditEvt()
      }
    },
    changeTableCallBack(response, site, params) {
      this.formFormatEditEvt()
    }
  }
}
</script>

<style lang="scss" scoped>
.after-sale-detail {
    .hx-box {
        padding: 8px 0;
    }

    .communication-img {
        margin:10px 20px 0 0;
        height: 110px;
        width: 110px;
        cursor: pointer;
    }

    .communication {
        font-size: 15px;
        line-height: 25px;
        border-bottom: 1px solid #f2f2f2;
        padding: 20px 0;
    }

    .form-group {
        .wlm-form {
            width: 500px;
            flex-grow: 1;
            margin-right: 20px;
        }
    }

    .total-money {
        font-size: 14px;
        margin-bottom: 58px;

        .total-title {
            display: inline-block;
            text-align: right;
            width: 70px;
            margin-right: 10px;
        }
    }

    .wlm-form {
        min-height: auto;
    }

    .wlm-form-steps {
        padding-top: 30px;
        padding-bottom: 30px;
    }
}
</style>
